#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include "motion/rtcmds.h"
#include "zuc/mot_cfg.h"

using namespace mot;
using namespace std;

class MotCmdsMock : public RtCmdItf
{
public:
    MOCK_METHOD0(active_callback, int());
    MOCK_METHOD0(process, int());
};

TEST(MotCmdSvrTest, call)
{
    mot::RtCmdSvr svr;
    auto cmd = std::make_shared<MotCmdsMock>();
    EXPECT_CALL(*cmd, active_callback()).WillOnce(testing::Return(0));
    EXPECT_EQ(svr.call(cmd), 0);
    EXPECT_CALL(*cmd, active_callback()).WillOnce(testing::Return(-1));
    EXPECT_EQ(svr.call(cmd), -3);
    EXPECT_CALL(*cmd, active_callback()).With(testing::_).Times(0);
    EXPECT_EQ(svr.call(cmd), -3);
}
TEST(MotCmdSvrTest, call_too_much)
{
    mot::RtCmdSvr svr;
    for (int i = 0; i < MOTCMD_MAX_CNT; i++)
    {
        auto cmd = std::make_shared<MotCmdsMock>();
        EXPECT_CALL(*cmd, active_callback()).WillOnce(testing::Return(0));
        EXPECT_EQ(svr.call(cmd), 0);
    }
    auto cmd = std::make_shared<MotCmdsMock>();
    EXPECT_CALL(*cmd, active_callback()).With(testing::_).Times(0);
    EXPECT_EQ(svr.call(cmd), -2);
}